package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class ReflectDemo6 {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        Class cla=Class.forName("reflect.Person");
       // Method method =cla.getMethod("sayHi");
        Method method =cla.getMethod("say",String.class,int.class);
        String name=method.getName();//获取方法名
        int modifier=method.getModifiers();//获取方法的修饰符
        switch (modifier){
            case Modifier.PUBLIC:
                System.out.println("public");
                break;
            case Modifier.PRIVATE:
                System.out.println("private");
                break;
            case Modifier.PROTECTED:
                System.out.println("protected");
                break;
        }
        Class returnType = method.getReturnType();
        System.out.println(returnType);
        int parameterCount = method.getParameterCount();
        System.out.println(parameterCount);
    }
    }

